<template>
    <van-cell title="请选择收货地址" is-link @click="shouh"/>
    <div v-for="item in cartData">
        <van-swipe-cell>
            <van-card :price="item.goods.goods_price" :title="item.goods.goods_name">
                <template #thumb>
                    <div style="display: flex;">
                        <van-checkbox v-model="item.checked"></van-checkbox>
                        <img :src="item.goods.goods_small_logo ? item.goods.goods_small_logo : 'https://fastly.jsdelivr.net/npm/@vant/assets/ipad.jpeg'"
                            alt="" style="width: 70px;height: 70px;">
                    </div>
                </template>
                <template #num>
                    <van-stepper v-model="item.number" theme="round" button-size="22" disable-input />
                </template>
            </van-card>
            <template #right>
                <van-button square text="删除" type="danger" class="delete-button" @click="del(item.id)"
                    style="height: 100%;" />
            </template>
        </van-swipe-cell>
    </div>
    <van-submit-bar :price="3050" button-text="提交订单" @submit="onSubmit">
        <van-checkbox v-model="checkedall">全选</van-checkbox>
    </van-submit-bar>
</template>

<script setup>
import { useCounterStore } from '@/stores/piniaCart'
// 在组件内部的任何地方均可以访问变量 `store` ✨
const store = useCounterStore()
import { ref, computed } from 'vue';
import { useRouter } from 'vue-router';
let router=useRouter()
let cartData = ref([])
let cart = () => {
    cartData.value = store.piniaCart
}
cart()
let del = (id) => {
    store.piniaCart = store.piniaCart.filter(item => item.id != id)
    cart()
}
let shouh=()=>{
    router.push('/shdz')
}
</script>

<style lang="scss" scoped></style>